<% layout('/layouts/default.html', {title: '任务部署信息表(主)管理', libs: ['dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header">
			<#form:form id="searchForm" model="${dcSupTaskInfo}" action="${ctx}/taskdeploy/dcSupTaskInfoSecretary/findListData?taskStatus=1&normalFlag=2" method="post" class="form-inline"
			data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
			<div style="float: right">
						<#form:hidden path="messageNumber"/>
				        <#form:hidden path="taskYear"/>
				        <#form:hidden path="taskTitle"/>
				        <#form:hidden path="taskTypeCode"/>
				         <#form:hidden path="searchType"/>
				<div class="form-group">
					<label class="control-label">${text('任务内容')}：</label>
					<div class="control-inline width-160">
						<#form:input path="taskContent" maxlength="200" class="form-control width-160" placeholder="请输入任务内容"/>
					</div>
				</div>
				<div class="form-group" >
					<button type="submit" class="btn btn-primary btn-sm">${text('查询')}</button>
					<button onclick="cz();" class="btn btn-default btn-sm">${text('重置')}</button>
				</div>
			</div>
		</#form:form>
	</div>
	<div class="box-body">
		<%
		var officeCode =@com.jeesite.modules.utils.OfficeUtil.getCurrentOffice().getOfficeCode();
		var userCode =@UserUtils.getUser().getUserCode();
		 %>
		<table id="dataGrid"></table>
		<div id="dataGridPage"></div>
	</div>
</div>
</div>
<% } %>
<script>
	//重置
	function cz(){
		searchForm.reset();
		$('#dataGrid').dataGrid('reloadGrid');
	}

	//打开新的标签
	function addTask() {
		js.addTabPage(null, "新增督办事项","${ctx}/taskdeploy/dcSupTaskInfo/form?normalFlag="+1, true);
	}
	function addTaskMulti() {
		js.addTabPage(null, "新增督办事项","${ctx}/taskdeploy/dcSupTaskInfo/multiForm?normalFlag="+2, true);
	}

	// 初始化DataGrid对象
	$('#dataGrid').dataGrid({
		searchForm: $("#searchForm"),
		sortableColumn: false, // 列表不允许排序
		columnModel: [
			{header:'${text("主键")}', name:'id', index:'a.id', width:150, align:"left", hidden:true},
			{header:'${text("督办字号")}', name:'messageNumber', index:'a.message_number', width:100, align:"left"
				, formatter: function(val, obj, row, act){
					if (val) {
						return val;
					} else {
						return "暂无字号";
					}
				}
			},
			{header:'${text("任务标题")}', name:'taskTitle', index:'a.task_title', width:150, align:"left"
				, formatter: function(val, obj, row, act){
					var messageNumber =encodeURIComponent(row.messageNumber);
					var taskTitle =encodeURIComponent(row.taskTitle);
					return '<a href="${ctx}/taskdeploy/dcSupTaskInfoSecretary/messageNumberForm?messageNumber='+messageNumber+'&taskYear='+row.taskYear+'&taskTitle='+taskTitle+'&taskTypeCode='+row.taskTypeCode+'" class="btnList" data-title="${text("牵头责任单位详情")}">'+(val||'暂无标题')+'</a>';
				}
			},
			{header:'${text("任务类型")}', name:'taskTypeName', index:'a.task_type_name', width:150, align:"left"},
			{header:'${text("任务内容")}', name:'taskContent', index:'a.task_content', width:150, align:"left"
				, formatter: function(val, obj, row, act){
					return '<a href="${ctx}/taskdeploy/dcSupTaskInfo/detailForm?id='+row.id+'" class="btnList" data-title="${text("督办任务信息")}">'+(val||'暂无内容')+'</a>';
				}
			},
			{header:'${text("任务状态")}', name:'taskStatus', index:'a.task_status', width:150, align:"center"
				,formatter: function(val, obj, row, act){
					return js.getDictLabel(${@DictUtils.getDictListJson('dc_task_status')}, val, '${text("未知")}', true);
				}},
			{header:'${text("操作")}', name:'actions', width:150, align:"center",formatter: function(val, obj, row, act){
					var actions = [];
					if(row.taskStatus=='1'||row.taskStatus=='4'||row.taskStatus=='6'){
						actions.push('<a href="#" class="btn btn-primary btn-xs " onclick=editTask("'+row.id+'") title="${text("编辑督办事项")}">编辑</a>&nbsp;&emsp;');}
					actions.push('<a href="${ctx}/taskdeploy/dcSupTaskInfo/deleteById?id='+row.id+'" class="btn btn-danger btn-xs btnList" title="${text("删除任务")}" data-confirm="${text("确认要彻底删除该任务吗？")}">删除</a>&nbsp;');
					return actions.join('');
			}}
		],
		// 加载成功后执行事件
		ajaxSuccess: function(data){

		}
	});

	// 编辑任务
	function editTask(id) {
		js.addTabPage(null, "编辑督办任务","${ctx}/taskdeploy/dcSupTaskInfo/form?id="+id , true);
	}

	// 导入
	$('#btnImport').click(function(){
		js.layer.open({
			type: 1,
			area: ['400px'],
			title: '${text("导入督办数据")}',
			resize: false,
			scrollbar: true,
			shadeClose: false,
			content: js.template('importTpl'),
			success: function(layero, index){
				layero.find('input[type="checkbox"]').iCheck();
			},
			btn: ['<i class="fa fa-check"></i> ${text("导入")}',
				'<i class="fa fa-remove"></i> ${text("关闭")}'],
			btn1: function(index, layero){
				var form = {
					inputForm: layero.find('#inputForm'),
					file: layero.find('#file').val()
				};
				if (form.file == '' || (!js.endWith(form.file, '.xls') && !js.endWith(form.file, '.xlsx'))){
					js.showMessage("${text('文件不正确，请选择后缀为“xls”或“xlsx”的文件。')}", null, 'warning');
					return false;
				}
				js.ajaxSubmitForm(form.inputForm, function(data){
					js.showMessage(data.message);
					if(data.result == Global.TRUE){
						js.layer.closeAll();
					}
					page();
				}, "json");
				return true;
			}
		});
	});
</script>